<template>
  <div class="customer-form">
    <slot name="title"></slot>
    <info-form :form="form" :type="type" ref="baseForm"></info-form>
    <slot name="save"></slot>
  </div>
</template>

<script lang="ts">
import { defineComponent, getCurrentInstance } from 'vue'
import infoForm from './info-form.vue'
export default defineComponent({
  name: 'CustomerForm',
  components: { infoForm },
  props: {
    type: {
      type: String,
      default: 'add'
    },
    form: {
      type: Object,
      default: () => ({})
    }
  },
  setup() {
    const instance: any = getCurrentInstance()

    const isCheckForm = () => {
      // 表单校验
      return instance?.refs.baseForm.isCheckForm()
    }

    return {
      isCheckForm
    }
  }
})
</script>

<style lang="stylus" scoped></style>
